package com.jelly.common.util;

import com.alibaba.fastjson.JSONObject;
import com.jelly.common.util.http.HttpUtils;

/**
 * @创建人 ql
 * @创建时间 2018-08-17 15:19
 * @功能描述: 获取地址详情
 **/
public class AddressUtil {

    public static String getRealAddressByIP(String ip)
    {
        String address = "";
        try{
            address = HttpUtils.sendPost("http://ip.taobao.com/service/getIpInfo.php", "ip="+ip);
            JSONObject json = JSONObject.parseObject(address);
            JSONObject object = json.getObject("data", JSONObject.class);
            String region = object.getString("region");
            String city = object.getString("city");
            address = region + " " + city;
        }
        catch (Exception e)
        {
        }
        return address;
    }

}
